/**
 * Date:2022年1月5日 下午3:38:52
 * Copyright (c) 2022, www.bwbroad.com All Rights Reserved
 */

package com.app.common.vo;

import java.io.Serializable;
import java.util.HashMap;

/**
 * Description: Debezium消息 <br/>
 * Date:2022年12月5日 下午3:38:52 <br/>
 * 
 * @author xuejianxin
 */
public class DebeziumMessage implements Serializable {
	private static final long serialVersionUID = 1L;

	// 事件类型参考
	// https://debezium.io/documentation/reference/2.1/connectors/mysql.html#mysql-events
	public static enum OpType {
		r, // 初始化快照读取
		c, // insert
		u, // update
		t, // truncate events 这个事件比较危险不做处理
		d, // delete
		e  // empty,delete 事件后跟着 墓碑消息dumb，该消息无消息体为空 
		;
	}

	protected String topicPrefix; // topic前缀
	protected OpType op; // 操作类型
	protected String table; // 操作的表
	protected String file; // bin log 文件
	protected String pos; // bin log 位置

	protected HashMap<String, Object> key;
	protected HashMap<String, Object> before;
	protected HashMap<String, Object> after;

	public String getTopicPrefix() {
		return topicPrefix;
	}

	public void setTopicPrefix(String topicPrefix) {
		this.topicPrefix = topicPrefix;
	}

	public OpType getOp() {
		return op;
	}

	public void setOp(OpType op) {
		this.op = op;
	}

	public String getTable() {
		return table;
	}

	public void setTable(String table) {
		this.table = table;
	}

	public String getFile() {
		return file;
	}

	public void setFile(String file) {
		this.file = file;
	}

	public String getPos() {
		return pos;
	}

	public void setPos(String pos) {
		this.pos = pos;
	}

	public HashMap<String, Object> getBefore() {
		return before;
	}

	public void setBefore(HashMap<String, Object> before) {
		this.before = before;
	}

	public HashMap<String, Object> getAfter() {
		return after;
	}

	public void setAfter(HashMap<String, Object> after) {
		this.after = after;
	}

	public HashMap<String, Object> getKey() {
		return key;
	}

	public void setKey(HashMap<String, Object> key) {
		this.key = key;
	}

	@Override
	public String toString() {
		return String.format(
				"DebeziumMessage [topicPrefix=%s, op=%s, table=%s, file=%s, pos=%s, key=%s, before=%s, after=%s]",
				topicPrefix, op, table, file, pos, key, before, after);
	}

}
